import QtQuick 1.0
import "Article.js" as ArticleUtil
 Item {
     id: delegate

     width: 80; height: 60

     property string  firstImageUp:"../images/articles/btn_1_up.png";
     property string  footImageUp:"../images/articles/btn_3_up.png";
     property string  otherImageUp:"../images/articles/btn_2_up.png";
     property string  firstImageDown:"../images/articles/btn_1_down.png";
     property string  footImageDown:"../images/articles/btn_3_down.png";
     property string  otherImageDown:"../images/articles/btn_2_down.png";
     property int allCount:6;


     Image{
       anchors.fill: parent
       source: delegate.ListView.isCurrentItem ?(index===0 ? firstImageDown:(index==(allCount-1)?footImageDown :otherImageDown)):(index===0 ?firstImageUp:(index==(allCount-1) ? footImageUp:otherImageUp))

     }

     Text {
         text: ArticleUtil.getArticleName(typeId,name)
         color: "black"
         font { family: "Helvetica"; pointSize: 16; bold: true }
         anchors {
             //left: parent.left; leftMargin: 15
             verticalCenter: parent.verticalCenter
             horizontalCenter:parent.horizontalCenter
         }
     }

     Component.onCompleted: {
         if(delegate.ListView.isCurrentItem){
             console.log("init menu currentTypeId:"+typeId);
              article_page.currentTypeId = typeId;
             //ArticleUtil.setCurrentMenuIndex(index);
             // delegate.ListView.view.currentIndex=index;
         }
     }

     MouseArea {
         anchors.fill: delegate
         onClicked: {

             delegate.ListView.view.currentIndex=index


             article_page.currentTypeId = typeId   //model 中的 属性：文章id

             article_page.article_list_url =article_page.base_url+"&Page="+article_page.pageIndex+"&count="+article_page.pageSize+"&TypeId="+typeId+"&CityId="+article_page.currentCity;

             article_page.loaderArticle();//加载文章列表

             console.log("get url:"+article_page.article_list_url);
             console.log("current index:"+index);
             console.log("current typeId:"+typeId);

         }
     }
 }
